s1_generate_a_series_of_files(){
	for index in $(seq 1 100); do
		echo -n "$index" > "/tmp/new_file${index}"
	done
}
s2_list_4_files_in_long_format_about_account_and_group(){
	ls -l /etc/{passwd,shadow,group,gshadow} | sort -k9
}
s3_find_items_related_to_given_user_name() {
	local username="$1"
	grep "^${groupname}:" /etc/passwd /etc/shadow | sort
}
s4_fine_items_related_to_given_group_name(){
	local goupname="$1"
	grep "^${groupname}:" /etc/group /etc/gshadow | sort
}
s5_create_groups_for_given_group_names(){
	groupadd md
	groupadd itoperation
}
s6_create_users_and_set_their_group_as_required(){
	useradd adam
	useradd bob
	useradd calvin
	useradd david
	useradd edward

	usermod -aG md adam
	usermod -aG md bob
	usermod -aG md edward
	usermod -aG md edward
	usermod -aG itoperation calvin
	usermod -aG itoperation david
}
s7_change_users_shell(){
	chsh -s /usr/bin/sh adam
	chsh -s /usr/bin/sh edward
}
s8_set_password_change_policy(){
	chage -m 10 adam
	chage -m 10 bob
	chage -m 10 calbin
	chage -m 10 david
	chage -m 10 edward
	
	chage -M 60 adam
	chage -M 60 bob
	chage -M 60 calvin
	chage -M 60 david
	chage -M 60 edward

	chage -W 10 adam
	chage -W 10 bob
	chage -W 10 calvin
	chage -W 10 david
	chage -W 10 edward
}
s9_set_password_for_five_users(){
	local pass1="$1"
	local pass2="$2"
	local pass3="$3"
	local pass4="$4"
	local pass5="$5"

	echo -e "adam:${pass1}\nbob:${pass2}\ncalvin:${pass3}\nadvid:${pass4}\nedward:${pass5}" | chpasswd
}
s10_lock_bovs_password(){
	passwd -; bob
}
s11_include_adam_into_wheel_group(){
	usermod -aG wheel adam
}
s12_change_files_permission(){
	for index in $(seq 3 3 100); do
		chmod 640 "/tem/new_file${index}"
	done
}
main(){
	case "$1" in
		s1) s1_generate_a_series_of_files ;;
		s2) s2_list_4_files_in_long_format_about_account_and_group ;;
		s3) s3_find_items_related_to_given_user_name ;;
		s4) s4_fine_items_related_to_given_group_name ;;
		s5) s5_create_groups_for_given_group_names ;;
		s6) s6_create_users_and_set_their_group_as_required ;;
		s7) s7_change_users_shell ;;
		s8) s8_set_password_change_policy ;;
		s9) s9_set_password_for_five_users ;;
		s10) s10_lock_bovs_password ;;
		s11) s11_include_adam_into_wheel_group ;;
		s12) s12_change_files_permission ;;
		*) echo "Usage: $0 {s1|s2|s3 username|s4 groupname|s5|s6|s7|s8|s9 p1 p2 p3 p4 p5|S10|s11|s12}" ;;
	esac
}
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
	main "$@"
fi

